/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package grlu;

import DAO.DirectorJpaController;
import DAO.PersonJpaController;
import DAO.exceptions.NonexistentEntityException;
import DAO.exceptions.PreexistingEntityException;
import Entidad.Director;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 *
 * @author usuario10
 */
public class ASDF {
    public static EntityManagerFactory emf;
    public static EntityManager em;
    
    public ASDF() throws NonexistentEntityException, PreexistingEntityException, Exception {
        //inicializacion();
        emf = Persistence.createEntityManagerFactory("GRLUPU", System.getProperties());
        
        Director  a = new Director();
        a.setName("Hola");
        a.setLastName("Rodriguez");
        a.setBirthDate(new Date());
        a.setBirthPlace("Ibague");
        a.setPicture("Forigua");
        
        DirectorJpaController DirectorJPA = new DirectorJpaController(emf);
        PersonJpaController PersonJPA = new PersonJpaController(emf);
        
        DirectorJPA.create(a);
        PersonJPA.destroy("Hola");
        emf.close();
    }
    public static void main(String[] args) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                try {
                        ASDF asdf = new ASDF();
                } catch (Exception ex) {
                    Logger.getLogger(ASDF.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });
    }

}
